import java.util.Scanner;

public class Day15 {

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int x = in.nextInt();
            int sum = 0;
            int min = 0;
            for(int i = 0;i < 100; i++){
                if(func(i)){
                    int tmp = sum;
                    sum = Math.abs(x - i);
                    min = Math.min(sum,tmp);
                }
            }
            System.out.print(min);
        }
    }

    public static boolean func(int y){
        for(int i = 0;i < y; i++){
            int x = i * i;
            if(y == x){
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            // 注意 hasNext 和 hasNextLine 的区别
            while (in.hasNextInt()) { // 注意 while 处理多个 case
                int n = in.nextInt();
                int m = in.nextInt();
                int max = 0;
                int[] arr = new int[m];
                for(int i = 0;i < n;i++){
                    arr[i] = in.nextInt();
                }

                //找到数目最多的元素
                int[] hash = new int[n];
                for(int i = 0; i < n; i++){
                    hash[arr[i]]++;
                }
                for(int i = 0; i < n; i++){
                    if(hash[max] < hash[i]){
                        max = i;
                    }
                }

                if(hash[max] > (n+1)/2){
                    System.out.print(-1);
                    return;
                }else{

                }
            }
        }

}
